home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 11494 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.5 KB

  1. Path: solon.com!not-for-mail
  2. From: vanyo@ibcco.com (Bill Vanyo)
  3. Newsgroups: comp.lang.c,comp.lang.c.moderated
  4. Subject: Re: Multiple Indirection (Pointer Arithmatic)
  5. Date: 24 Mar 1996 11:51:04 -0600
  6. Organization: ABSnet Internet Services, Inc. - info@abs.net - (410)-361-8160
  7. Sender: clc@solutions.solon.com
  8. Approved: clc@solutions.solon.com
  9. Message-ID: <4j4228$nvv@solutions.solon.com>
  10. References: <4j06ig$7q8@solutions.solon.com>
  11. NNTP-Posting-Host: solutions.solon.com
  12. X-Nntp-Posting-Host: ppp-175.ezaccess.net
  13. X-Newsreader: Forte Free Agent 1.0.82
  14.  
  15. R.Ghosh-Roy@brunel.ac.uk (R Ghosh-Roy) wrote:
  16.  
  17.  
  18.  >I am a bit confused about "pointer arithmatic" and therefore would appreciate
  19.  >your expert help. The following is the problem:
  20.  
  21. Perhaps you're not confused.
  22.  
  23.  >I have three arrays (A,B,C) of structures and each structure has its own set
  24.  >of fields. In structure A, one particular field Ab points to structure B. B
  25.  >has a field Bc which points to C and C has a field named Cd. I need to look
  26.  >for Cd for each A. Can I use some kind of clever pointer arithmatic to get
  27.  >to Cd for each A? Or, is there a cleverer way?
  28.  
  29. I'm going to go out on a limb here and say that there is no quicker
  30. way than to follow the 2 links. 
  31.  
  32.  >Note: 3 arrays of structures A,B and C and only one field relates elements
  33.  >      of each array, ie, Ab relates to an element within an array of Bs and
  34.  >      Bc relates to an element within an array of Cs. These are dynamically
  35.  >      assigned.
  36.  
  37.  >struct A
  38.  >|--------|
  39.  >|        |
  40.  >|        |
  41.  >|        |
  42.  >|        |        struct B
  43.  >| Ab  ---|------->|--------|
  44.  >|        |        |        |
  45.  >|--------|        |        |
  46.  >                  |        |
  47.  >                  |        |
  48.  >                  |        |         struct C
  49.  >                  | Bc  ---|-------->|----------|
  50.  >                  |        |         |          |
  51.  >                  |        |         |          |
  52.  >                  |        |         |          |
  53.  >                  |--------|         |          |
  54.  >                                     |          |
  55.  >                                     |  Cd      |
  56.  >                                     |          |
  57.  >                                     |          |
  58.  >                                     |          |
  59.  >                                     |          |
  60.  >                                     |----------|
  61.  
  62.  >I was thinking of using sizeof and offsetof expressions. 
  63.  
  64.  >Thanks,
  65.  
  66.  >Rana
  67.  
  68.  
  69.  >-- 
  70.  >R. Ghosh-Roy @ BIPS  -- R.Ghosh-Roy@brunel.ac.uk -- Extension 2772
  71.